local skel = fk.CreateSkill {
  name = "emo__jianming",
  tags = {Skill.Compulsory},
}

skel:addEffect(fk.Damage, {
  name = "emo__jianming",
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and data.extra_data and data.extra_data.emo__jianming_check
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local skill = Fk.skills["emo__chaofeng"]
    if skill and skill:isInstanceOf(ActiveSkill) then
      ---@cast skill ActiveSkill
      for _ = 1, data.extra_data.emo__jianming_check do
        skill:onUse(room, SkillUseData:new {
          from = player,
          cards = {},
          tos = {},
        })
      end
    end
  end,
})

-- 检测所有角色造成的伤害，计算能触发多少次技能
skel:addEffect(fk.Damage, {
  can_refresh = function (self, event, target, player, data)
    return player == target and target:isFemale()
  end,
  on_refresh = function (self, event, target, player, data)
    local room = player.room
    local sum = (room:getTag("emo__jianming_count") or 0) + data.damage
    local n = sum // 3
    room:setTag("emo__jianming_count", sum % 3)
    if n > 0 then
      data.extra_data = data.extra_data or {}
      data.extra_data.emo__jianming_check = n
    end
  end,
})

Fk:loadTranslationTable{
  ["emo__jianming"] = "涧鸣",
  [":emo__jianming"] = "锁定技，当女性角色每累计造成3点伤害后，你发动一次〖朝凤〗。",
}


return skel
